
<div class="popbg" id="openTrade">
    <ul class="pul">
        <li><span>品种：<span class="yellow"><?php echo $desc;?></span></span>
        <span class="pdl10">方向：<?php echo ($action=='bid')?'<font class="red">买涨</font>':'<font class="green">买跌</font>';?></span>
        </li>
        <li><span>最新价：<span id="<?php echo $name;?>_LAST_PRICE_SHOW"><span id="<?php echo $name;?>_LAST_PRICE2">-</span><span id="<?php echo $name;?>_UPARR2">-</span></span></span>
        <li>选择单位：
            <span>
                <label class="lh20">
                    <input type="radio" name="dtype" id="dtype-cny" value="cny" checked="checked"><label for="dtype-cny">人民币</label> &nbsp;&nbsp;
                    <input type="radio" name="dtype" id="dtype-ticket" value="ticket"><label for="dtype-ticket">体验券</label>
                </label>                    
            </span>
        </li>
        
        </li>
        <li>选择手数：
            <span>
                <button type="button" onclick="changeAmount('-')" class="btn btn-default btn-sm">&nbsp;&nbsp;<font style="padding:0 10px">-</font>&nbsp;&nbsp;</button>
                <input type="text" class="form-control inpw text-center input-sm" name="marketOpenNum" id="marketOpenNum" >
                <button type="button" onclick="changeAmount('+')" class="btn btn-default btn-sm">&nbsp;&nbsp;<font style="padding:0 10px">+</font>&nbsp;&nbsp;</button>
            </span>
            
        </li>
        <li class="dline"></li>
        <li>盈亏波动：<span class="yellow1"><?php echo $index;?>元</span>/点</li>
        <li><span class="pblock">保证金：10元/手</span><span>手续费：0.5元/手</span></li>
        <li class="text-center"><botton class="btn btn-warning btnw" onclick="marketOpenHandel('<?php echo $name;?>','<?php echo $action;?>',<?php echo $pid;?>)">市价下单</botton></li>
    </ul>
</div>
<script type="text/javascript">
    var indexVal = 4;
    var amountArr = [1,2,3,5,10,20,30,50,100,200,300,400,500];
    var initVal = 10;
    $('#marketOpenNum').val(initVal);
    function changeAmount(oper){
        var dtype = $("#openTrade input[name='dtype']:checked").val();
        if(dtype=='ticket'){
            if(oper=='-'){
                initVal--;
            }else{
                initVal++;
            }
            if(initVal<=1) initVal=1;
            if(initVal>=500) initVal=500;
            $('#openTrade #marketOpenNum').val(initVal);
        }else{
            var len = amountArr.length-1;
            if(oper=='-'){
                indexVal--;
            }else{
                indexVal++;
            }
            if(indexVal<=0) indexVal=0;
            if(indexVal>=len) indexVal=len;
            $('#openTrade #marketOpenNum').val(amountArr[indexVal]);
        }
        
    }

    $(function(){
        $("#openTrade input[name='dtype']").click(function(){
            var dtype = $(this).val();
            if(dtype=='cny'){
                initVal=10;
                indexVal=4;
            }else{
                initVal=1;
            }
            $('#openTrade #marketOpenNum').val(initVal);
        });
    });

</script>